<!DOCTYPE html>
<html>
<head>
    <title>{$site_name}-会员中心-添加会员</title>
    <meta name="keywords" content="{$site_seo_keywords}" />
    <meta name="description" content="{$site_seo_description}">

    <style type="text/css">
        #two-con{
            width: 700px;
        }

        #two-con .control-label {
            float: left;
            width: 90px;
            padding-top: 5px;
            text-align: right;
        }
        #two-con input.span4{
            width: 200px;
        }
        #two-con select{
            height: 34px;
            line-height: 34px;
        }
        #two-con select.span4{
            width: 214px;
        }
        /*tips*/
        #two-con .help-inline {
            display: block;
            margin-bottom: -20px;
            *zoom: 1;
            font-size: 14px;
        }
        #two-con .controls {
            *display: inline-block;
            *padding-left: 20px;
            margin-left: 120px;
            *margin-left: 0
        }
    </style>
    <tc_include file="Public:head" />

</head>


<body class="body-white" id="top">
<tc_include file="Public:nav" />

<div class="container tc-main">
    <div class="row">
        <div class="span2">
            <tc_include file="Public:usernav"/>
        </div>
        <div class="span10">

            <form class="form-horizontal" id="dd" action="{:leuu('User/Integral/adduser')}">
                <div id="two-con">
                    <div style="float: left;">
                            <div class="control-group">
                                <label class="control-label" for="cardnum"><span style="color: red;">*</span>服务卡号:</label>
                                <div class="controls">
                                    <input type="text" id="cardnum" name="cardnum" class="span4">
                                    <span class="help-inline"></span>
                                </div>
                            </div>

                            <div class="control-group">
                                <label class="control-label" for="name">姓名:</label>
                                <div class="controls">
                                    <input type="text" id="name" name="name" class="span4" style="width: 120px;float: left;">
                                    <select name="sex" id="sex" style="width: 70px;float: right;">
                                        <option value="1">先生</option>
                                        <option value="2">女士</option>
                                    </select>
                                    <span class="help-inline"></span>
                                    <div style="clear: both;"></div>
                                </div>
                            </div>
                        <div class="control-group">
                            <label class="control-label" for="shenfenzheng">积分金额:</label>
                            <div class="controls">
                                <input type="text" id="integral" name="integral" class="span4">
                                <span class="help-inline"></span>
                            </div>
                        </div>
                    </div>

                    <div style="float: right;">
                        <div class="control-group">
                            <label class="control-label" for="tel">关联卡号:</label>
                            <div class="controls">
                                <input type="text" id="ui_cardnum" name="ui_cardnum" class="span4 " data-container="body"
                                       data-toggle="popover"
                                       data-content="无此卡号信息!" onfocusout="getUserInfo(this.value)">
                                <span class="help-inline" id="ui_cardnum_show"></span>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label" for="tel">手机号码:</label>
                            <div class="controls">
                                <input type="text" id="tel" name="tel" class="span4">
                                <span class="help-inline"></span>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label" for="shenfenzheng">身份证号:</label>
                            <div class="controls">
                                <input type="text" id="shenfenzheng" name="shenfenzheng" class="span4">
                                <span class="help-inline"></span>
                            </div>
                        </div>
                    </div>

                    <div style="clear: both"></div>


                    <div class="control-group">
                        <label class="control-label" for="remark">备注:</label>
                        <div class="controls">
                            <textarea  id="remark" name="remark" style="width: 570px;height: 150px"></textarea>
                            <span class="help-inline"></span>
                        </div>
                    </div>
                </div>

                <div class="control-group" style="margin-top: 50px;">
                    <div class="controls">
                        <button class="btn btn-primary js-ajax-submit span4" type="button" style="margin-left: 0px" id="subbtn">确定</button>
                    </div>
                </div>
            </form>
        </div>

    </div>
    <tc_include file="Public:footer" />
</div>

<!-- /container -->
<tc_include file="Public:scripts" />
<script src="__PUBLIC__/js/tools.js"></script>
<script type="text/javascript">

    var reg_tel = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/;

    $('#subbtn').click(function() {
        var tel = $('#tel').val();

        if(tel!=""){
            if(tel.length==11){
                if(!reg_tel.test(tel)){
                    alert("手机号码不正确,请输入正确的手机号码!");
                    $('#tel').val("");
                    $('#tel').focus();
                    return false;
                }
            }
        }

        $.post("{:leuu('User/Integral/adduser')}",$('#dd').serialize(),function(data) {
            document.getElementById('subbtn').disabled=true;
            if(data.status == 1) {
                if(data.url) {
                    window.location.href=data.url;
                } else {
                    location.reload();
                }
            } else {
                alert(data.info);
                document.getElementById('subbtn').disabled=false;
            }
        })
    });

    function getUserInfo(ui_cardnum) {
        if(ui_cardnum==""){
           // alert("空的");
            return;
        }
        $.post("{:leuu('User/Integral/getUserInfo')}",{ui_cardnum:ui_cardnum},function(data) {
            if(data==null){
                $("#ui_cardnum").popover('show');
                //$("#ui_cardnum_show").html("此卡号没有信息!");
                $("#ui_cardnum").val("");
                $("#name").val("");
                $("#sex").val("");
                $("#tel").val("");
                $("#shenfenzheng").val("");
                return;
            }
            $("#name").val(data.name);
            $("#sex").val(data.sex);
            $("#tel").val(data.tel);
            $("#shenfenzheng").val(data.shenfenzheng);
        },'json');
    }


</script>
</body>
</html>